<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Notepad</title>

    <!-- bootstrap -->
    <link rel="stylesheet" href="./assets/css/bootstrap.min.css" />

    <!-- animate.css -->
    <link rel="stylesheet" href="./assets/css/animate.min.css" />
    <!-- boostarp -->
    <link rel="stylesheet" href="./assets/plugins/bootstrap-validator/bootstrapValidator.min.css" />

    <!-- mui -->
    <link rel="stylesheet" href="./assets/plugins/mui/css/mui.min.css" />

    <!-- 重置样式 -->
    <link rel="stylesheet/less" href="./assets/css/reset.less" />

    <!-- 公共样式 -->
    <link rel="stylesheet/less" href="./assets/css/common.less" />

    <!-- 页面独立的 -->
    <link rel="stylesheet/less" href="./assets/css/UserLogin.less" />
</head>

<body>
    <!-- 用户信息 -->
    <div class="user">
        <div class="avatar wow fadeInUp">
            <img src="./assets/images/avatar.png" />
        </div>

        <div class="notice wow fadeInUp" data-wow-delay="100ms">请填写已有账号或新注册账号</div>
    </div>

    <form id="login" class="login wow fadeInUp" data-wow-delay="200ms">
        <div class="form-group">
            <label for="mobile">手机号</label>
            <input type="text" class="form-control" id="mobile" name="mobile" placeholder="请输入手机号码" required />
        </div>

        <div class="form-group">
            <label for="password">密码</label>
            <input type="password" class="form-control" id="password" name="password" placeholder="请输入密码" required />
        </div>
        <div class="form-group">
            <label for="nickname">昵称</label>
            <input type="nickname" class="form-control" id="nickname" name="nickname" placeholder="请输入昵称" required />
        </div>

        <div class="action">
            <button class="btn">注册</button>
        </div>
        <div class="action" style="text-align: center;">
            <a href="./login.html">登录页面</a>
        </div>

    </form>
</body>

</html>
<!-- 解析less的文件 -->
<script src="./assets/js/less.min.js"></script>

<!-- jquery  -->
<script src="./assets/js/jquery.min.js"></script>

<!-- bootstrap -->
<script src="./assets/js/bootstrap.min.js"></script>

<!-- wow.js -->
<script src="./assets/js/wow.min.js"></script>
<!-- boostarp -->
<script src="./assets/plugins/bootstrap-validator/bootstrapValidator.min.js"></script>

<!-- mui -->
<script src="./assets/plugins/mui/js/mui.min.js"></script>

<!-- 引入接口插件 -->
<script src="./assets/plugins/axios/axios.min.js"></script>
<script src="./assets/plugins/axios/request.js"></script>



<script>
    //实例化wow.js
    new WOW().init();

    // 实例化表单验证器
    $('#login').bootstrapValidator({
        // 填写配置项
        message: '表单内容不能为空',//所有字段默认错误信息
        // 图标 
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        // 需要验证字段
        fields: {
            //input的name属性
            mobile: {
                validators: {
                    notEmpty: {
                        message: '手机号不能为空'
                    },
                    stringLength: {
                        min: 11,
                        max: 11,
                        message: '手机号长度必须是11位',
                    },
                    regexp: {
                        regexp: /^1[3-9]\d{9}$/,
                        message: '手机号错误'
                    }
                },

            },
            password: {
                validators: {
                    notEmpty: {
                        message: '密码不能为空'
                    }
                }
            },
            nickname: {
                validators: {
                    notEmpty: {
                        message: '昵称不能为空'
                    }
                }

            }
        }
    });

    $('#login').submit(async function () {


        var bootstrapValidators = $('#login').data('bootstrapValidator');
        if (!bootstrapValidators.isValid()) {
            return false;

        }
        let data = {
            mobile: $('#mobile').val(),
            password: $('#password').val(),

        }

        //调取接口
        let result = await POST({ url: 'business/register', params: data })
        if (result.code == 1) {
            mui.toast(result.msg)
            setTimeout(() => {
                location.href = 'login.html'
            }, 1000);





        } else {
            mui.toast(result.msg)


        }

        console.log(result);
        return false;






    })
</script>